package main

import (
	"fmt"
	"os"

	logger "gitee.com/woodpile/wgs.ths.log.go"
)

func main() {
	SimpleLine()
}

const LoggerModuleSample int32 = 3
const LoggerModuleSample_A uint64 = 1 << 0
const LoggerModuleSample_B uint64 = 1 << 1

func SimpleLine() {
	logger.GlobalSwitch.Set(LoggerModuleSample, LoggerModuleSample_A|LoggerModuleSample_B)

	cfg := &logger.LoggerConfig{
		TimeFormat:             "%Y-%m-%d %H:%M:%S.%f",
		TimeFormatBufferLength: 27,

		SwitchChecker: logger.NewSwitchChecker(LoggerModuleSample, LoggerModuleSample_A),
	}
	l, err := logger.NewLogger(cfg)
	if err != nil {
		fmt.Printf("Error exit: %v\n", err)
		os.Exit(1)
		return
	}

	Logging(l)
}

func Logging(l *logger.Logger) {
	l.DBG().Msg("Hello, world!").Z()
	logger.GlobalSwitch.Unset(LoggerModuleSample, LoggerModuleSample_B)
	l.DBG().Msg("After Switch Close B").Z()
	logger.GlobalSwitch.Unset(LoggerModuleSample, LoggerModuleSample_A)
	l.DBG().Msg("After Switch Close A").Z()
	logger.GlobalSwitch.Set(LoggerModuleSample, LoggerModuleSample_B)
	l.DBG().Msg("After Switch Open B").Z()
	logger.GlobalSwitch.Set(LoggerModuleSample, LoggerModuleSample_A)
	l.DBG().Msg("After Switch Open A").Z()
}
